vim.g.encoding = "utf-8"
vim.g.termencoding = "utf-8"
vim.g.fileencodings = "utf-8,ucs-bom,cp936,gb18030,big5,latin1"
vim.g.fileencoding = "utf-8"

-- 鼠标工作模式
vim.opt.mouse:append "a"
-- 共享剪贴板
vim.opt.clipboard:append { "unnamedplus" } -- use system clipboard as default register
vim.opt.clipboard:prepend { "unnamed", "unnamedplus" }

-- line numbers
vim.opt.relativenumber = true -- show relative line numbers
vim.opt.number = true         -- shows absolute line number on cursor line (when relative number is on)

-- 突出当前行 cursor line
vim.opt.cursorline = true -- highlight the current cursor line

-- turn on termguicolors for nightfly colorscheme to work
-- (have to use iterm2 or any other true color terminal)
vim.opt.termguicolors = true -- enabl 24-bit RGB color in the TUI
vim.opt.background = "dark"  -- colorschemes that can be light or dark will be made dark
-- 编辑器左侧会多一列, 显示一些图标指示
vim.opt.signcolumn = "yes"   -- show sign column so that text doesn't shift

-- 右侧参考线
vim.opt.colorcolumn:append "80"
vim.opt.colorcolumn:append "100"
vim.opt.colorcolumn:append "120"
vim.opt.colorcolumn:append "140"

-- tabs & indentation
vim.opt.expandtab = true  -- tabs are spaces, mainly because of python
vim.opt.tabstop = 2       -- 2 spaces for tabs (prettier default)
vim.opt.shiftwidth = 2    -- 2 spaces for indent width
vim.opt.softtabstop = 2   -- number of spacesin tab when editing
vim.opt.autoindent = true -- copy indent from current line when starting new one

-- 自动读写改变的文本
vim.opt.autoread = true
vim.opt.autowrite = true

-- 撤销数据文件存储
vim.opt.undofile = true
-- persistent undo
vim.bo.undofile = true
-- opt.undodir = vim.fn.expand("$HOME/.local/share/nvim/undo")
-- vim.opt.undodir = vim.fn.expand "$HOME/.config/nvim/.tmp/undo"
-- vim.notify(os.getenv("HOME") .. "/.config/nvim/.tmp/undo")
vim.opt.undodir = vim.fn.expand(os.getenv "HOME" .. "/.config/nvim/.tmp/undo")

-- Searching
vim.opt.incsearch = true  -- search as characters are entered
vim.opt.hlsearch = true   -- do not highlight matches
vim.opt.ignorecase = true -- ignore case when searching
vim.opt.smartcase = true  -- if you include mixed case in your search, assumes you want case-sensitive

-- split windows
vim.opt.splitright = true -- split vertical window to the right
vim.opt.splitbelow = true -- split horizontal window to the bottom

-- line wrapping
vim.opt.wrap = false     -- disable line wrapping

vim.opt.swapfile = false -- turn off swapfile

-- 可通过命令自定递增递减的字符 (默认快捷键是 Ctrl + a 递增, Ctrl + x 递减)
vim.opt.nrformats = "bin,hex,alpha"

-- 不使用原生的底下状态栏模式显示,可以使用 lualine.nvim 插件更美观
vim.opt.showmode = false -- we are experienced, wo don't need the "-- INSERT --" mode hint

-- backspace
vim.opt.backspace = "indent,eol,start" -- allow backspace on indent, end of line or insert mode start position
vim.opt.list = true
vim.opt.listchars:append "eol:↴" -- "eol:↴"
vim.opt.listchars:append "tab:  " -- "tab:>~"

-- vim.opt.listchars:append("space:⋅") -- "space:⋅"

-- vim.opt.listchars:append "eol:⤶"
-- vim.opt.listchars:append "extends:→"
-- vim.opt.listchars:append "precedes:←"
-- vim.opt.listchars:append "nbsp:■"
-- tab:…»■,trail:■
-- vim.opt.listchars:append("space:·") -- "space:·"
-- vim.opt.listchars:append("eol: ")   -- "eol:↴"
-- vim.opt.listchars:append("tab:  ")  -- "tab:>~"
-- vim.opt.fillchars = {
--   stl = " ",
--   stlnc = "-",
--   msgsep = " ",
--   foldopen = "",
--   foldclose = "",
--   fold = " ",
--   foldsep = " ",
--   diff = "╱",
--   eob = " ",
-- }

vim.opt.foldcolumn = "1" -- '0' is not bad
vim.opt.foldenable = true
vim.opt.foldlevel = 99   -- Using ufo provider need a large value, feel free to decrease the value
vim.opt.foldlevelstart = 99

-- Finding files - Search down into subfolders
vim.opt.path:append "**"
vim.opt.wildignore:append {
  "*/node_modules/*",
  "*/target/*",
}
